package com.evildog.workspace.system.api.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Objects;

/**
 * <p>
 * apiPermission
 * </p>
 *
 * @author evildog
 * @since 2020-07-25
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value="ApiPermission视图对象", description="接口/url权限表,即后端权限（全局权限，极端情况下，包含所有url）")
public class ApiPermissionVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 接口没有指定特殊的请求方法时，即ApiPermission限定了所有method的请求
     */
    public static final String ALLOW_ALL_METHOD = "*";

    @ApiModelProperty(value = "接口路径 可使用ant风格路径")
    private String path;

    @ApiModelProperty(value = "请求方式")
    private String method;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ApiPermissionVO that = (ApiPermissionVO) o;
        return path.equals(that.path) &&
                method.equalsIgnoreCase(that.method);
    }

    @Override
    public int hashCode() {
        return Objects.hash(path, method);
    }
}
